<?php 
namespace plugin;
class Admin extends \Plugin {
	
	protected $_admin_auth = 1;

	public function index(){
		if (\Ebcms::isPost()) {
			$cfg = [
				'expire' => \mylib\Input::post('expire', 3600),
				'tips' => \mylib\Input::post('tips', '')
			];
			file_put_contents(__DIR__ . '/../cfg.php', '<?php '.PHP_EOL.'return ' . var_export($cfg, true) . ';');
			return $this -> success('操作成功！');
		}else{
			$cfg = include __DIR__ . '/../cfg.php';
			$cfg = array_merge(['expire'=>3600,'tips'=>''], (Array)$cfg);
			$this -> assign('cfg', $cfg);
			return \mylib\Response::html($this -> fetch());
		}
	}
}